import Vue from 'vue'
import Router from 'vue-router'
import _import from './_import'
import Layout from '@/views/layout/Layout'

Vue.use(Router)


export const page401 = {
    path: '/401',
    name: '401-权限不足',
    component: _import('error_page/page-404'),
    hidden: true
};


export const page404 = {
    path: '/*',
    name: '404-页面不存在',
    component: _import('error_page/page-404'),
    hidden: true
};

export const page500 = {
    path: '/500',
    name: '500-服务端错误',
    component: _import('error_page/page-500'),
    hidden: true
};


export const index = {
    path: '/',
    redirect: '/dashboard/index',
    hidden: true
}

export const dashboardRouter = {
    path: '/dashboard',
    component: Layout,
    noDropDown: true,
    children: [
        { path: 'index', name: '控制台', component: _import('dashboard/index') }
    ]
}

export const loginRouter = {
    path: '/login',
    name: '登录',
    component: _import('login/index'),
    hidden: true
};

export const asyncAppRouter = [
    {
        path: '/upms',
        name: '授权中心',
        component: Layout,
        redirect: 'noredirect',
        children: [
            {path: 'app', name: '应用管理', component: _import('upms/App')},
            {path: 'menu', name: '菜单管理', component: _import('upms/Menu')},
            {path: 'permission', name: '权限管理', component: _import('upms/Permission')},
            {path: 'organization', name: '组织管理', component: _import('upms/Organization')},
            {path: 'user', name: '用户管理', component: _import('upms/User')},

            {path: 'role', name: '角色管理', component: _import('upms/role/index')},
            {path: 'role_user_list', name: '角色户列表', component: _import('upms/role/RoleUserList'), hidden: true},
            {path: 'role_add_permission', name: '添加权限', component: _import('upms/role/AddPermission'), hidden: true},

            {path: 'group', name: '群组管理', component: _import('upms/group/index')},
            {path: 'group_user_list', name: '组用户列表', component: _import('upms/group/GroupUserList'), hidden: true},
            /*{
                path: '/upms/role',
                component: _import('upms/Role'),
                redirect: '/upms/role/index',
                noDropDown: true,
                children: [
                    {path: 'index', name: '角色管理', component: _import('upms/role/index')},
                    {path: 'role_user_list', name: '角色户列表', component: _import('upms/role/RoleUserList')},
                    {path: 'role_add_permission', name: '添加权限', component: _import('upms/role/AddPermission')}
                ]
            },
            {
                path: '/upms/group',
                component: _import('upms/Group'),
                redirect: '/upms/group/index',
                noDropDown: true,
                children: [
                    {path: 'index', name: '群组管理', component: _import('upms/group/index')},
                    {path: 'group_user_list', name: '组用户列表', component: _import('upms/group/GroupUserList')}
                ]
            },*/
        ]
    },
    {
        path: '/example',
        component: Layout,
        redirect: 'noredirect',
        name: '综合实例',
        icon: 'zonghe',
        children: [
            {
                path: '/example/table',
                component: _import('dashboard/index'),
                redirect: '/example/table/table',
                name: 'Table',
                icon: 'table',
                children: [
                    { path: 'dynamictable', component: _import('dashboard/index'), name: '动态table' },
                    { path: 'dragtable', component: _import('dashboard/index'), name: '拖拽table' },
                    { path: 'inline_edit_table', component: _import('dashboard/index'), name: 'table内编辑' },
                    {
                        path: 'table', component: _import('dashboard/index'), name: '综合table',
                        children: [
                            { path: 'dynamictable1', component: _import('dashboard/index'), name: '动态table1' },
                            { path: 'dragtable1', component: _import('dashboard/index'), name: '拖拽table1' },
                            { path: 'inline_edit_table1', component: _import('dashboard/index'), name: 'table内编辑1' },
                            { path: 'table1', component: _import('dashboard/index'), name: '综合table1' }
                        ]
                    }
                ]
            },
            { path: 'form/edit', icon: 'shouce', component: _import('dashboard/index'), name: '编辑Form', meta: { isEdit: true }},
            { path: 'form/create', icon: 'from', component: _import('dashboard/index'), name: '创建Form' },
            { path: 'tab/index', icon: 'tab', component: _import('dashboard/index'), name: 'Tab' }
        ]
    },

    page404
]



export const constantRouters = [
    index,
    dashboardRouter,
    loginRouter,
    page401,
    page500
]

export default new Router({
    routes: constantRouters
})